﻿using Dapper;
using System.Collections.Generic;
using System.Data.SqlClient;
using yunbo.Model.SM;

namespace yunbo.Repositorys.SMRepositorys
{
    public class WMS_CKXXRepository
    {
        public string data = "Data Source=121.37.93.71;Initial Catalog=FanXingMES;User ID=sa;Password=geili@2025;";
        public int PostWMXX_CK(TJWMS_CKXX tjwm_ckxx)
        {
            using (SqlConnection connection = new SqlConnection(data))
            {
                string sql = $"insert into wms_ckxx(ckxx_code,ckb_code,wl_code,ckxx_wlmc,ckxx_wlfl,ckxx_ggxh,ckxx_cksl,kc_code)values\r\n" +
                    $"('{tjwm_ckxx.ckxx_code}','{tjwm_ckxx.ckb_code}','{tjwm_ckxx.wl_code}','{tjwm_ckxx.ckxx_wlmc}','{tjwm_ckxx.ckxx_wlfl}','{tjwm_ckxx.ckxx_ggxh}',{tjwm_ckxx.ckxx_cksl},'{tjwm_ckxx.kc_code}')";
                int rs = connection.Execute(sql);
                return rs;
            }
        }
        public List<WMS_CKXX> GetWMXX_CK(string code)
        {
            using (SqlConnection connection = new SqlConnection(data))
            {
                string sql = $"select * from wms_ckxx\r\nwhere ckb_code='{code}'";
                List < WMS_CKXX > wMS_CKXXes = connection.Query<WMS_CKXX>(sql).ToList();
                return wMS_CKXXes;
            }
        }
    }
}
